package com.jxaummd.mushroom.main.common.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.EditText;


import com.jxaummd.mushroom.R;
import com.jxaummd.mushroom.R2;
import com.jxaummd.mushroom.core.base.fragment.PresenterFragment;
import com.jxaummd.mushroom.main.common.contract.ForgetPasswordSendCodeContract;
import com.jxaummd.mushroom.main.common.presenter.ForgetPasswordSendCodePresenter;

import butterknife.BindView;
import butterknife.OnClick;

public class ForgetPasswordSendCodeFragment extends PresenterFragment<ForgetPasswordSendCodeContract.Presenter>
        implements ForgetPasswordSendCodeContract.View{

    public static ForgetPasswordSendCodeFragment newInstance() {
        Bundle args = new Bundle();
        ForgetPasswordSendCodeFragment fragment = new ForgetPasswordSendCodeFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @BindView(R2.id.ec_et_common_forget_password_phonenumber)
    EditText mEditPhoneNumber = null;

    @OnClick(R2.id.ec_ib_common_forget_password_close)
    public void close(){
        pop();
    }


    @OnClick(R2.id.ec_btn_common_forget_password_get_testcode)
    public void getCode(){
        mPresenter.sendCode(mEditPhoneNumber.getText().toString());
    }

    @Override
    protected ForgetPasswordSendCodeContract.Presenter initPresenter() {
        return new ForgetPasswordSendCodePresenter(this);
    }


    @Override
    public Object setLayout() {
        return R.layout.common_forget_password_sendcode;
    }


    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, View rootView) {
        mPresenter.start();
        hideSoftInput();
    }

    @Override
    public void sendSuccess() {
        startWithPop(ForgetPasswordFragment.newInstane(mEditPhoneNumber.getText().toString()));
    }
}
